<?php
date_default_timezone_set('Asia/Shanghai');//时区配置
$conn=mysql_connect("localhost","root","gsda1.mysql1");
include 'functions.php';
mysql_select_db("new_gsdai", $conn);
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $conn);
$value['user_id'] = 6511;
$account_result_reward 	= db_fetch_array("select * from ych_account where user_id=6511", $conn);
$log['user_id'] 		= $value['user_id'];
$log['ftype'] 			= 36;
$log['money'] 			= 61.04;
$log['total'] 			= $account_result_reward['total'];
$log['use_money'] 		= $account_result_reward['use_money']+$log['money'];
$log['no_use_money'] 	= $account_result_reward['no_use_money'];
$log['collection'] 		= $account_result_reward['collection']-$log['money'];
$log['to_user'] 		= "1";
$log['remark'] 			= "[<a href=\'/borrow/obj/2455.html\'>五金制品公司资金周转</a>]的还款";
$log['add_time'] 		= time();
$log['addip'] 			= '127.0.0.1';
$mode = $value['user_id']%100;
$sql  ="insert into ych_account_log_$mode(user_id,ftype,total,money,use_money,no_use_money,
												collection,to_user,remark,add_time,addip) values( 
			 {$value['user_id']},{$log['ftype']},{$log['total']},{$log['money']},
			 {$log['use_money']},{$log['no_use_money']},
			 {$log['collection']},{$log['to_user']},'{$log['remark']}',
			 {$log['add_time']},'{$log['addip']}'
			 )";
$query = mysql_query($sql, $conn);
if(!$query){
	echo $sql;
	exit;
}
$query = mysql_query("update ych_account set use_money=use_money+{$log['money']},
						collection=collection-{$log['money']} where user_id={$value['user_id']}", $conn);
if(!$query){
	echo $sql;
	exit;
}

